const showToast = (title = "", icon = "none", duration = 2000, mask = false) => {
  return new Promise((resolve, reject) => {
    wx.showToast({
      title: title,
      icon: icon,
      duration: duration,
      mask: mask,
      success() {
        resolve(true)
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

const showLoading = (title = "", ) => {
  return new Promise((resolve, reject) => {
    wx.showLoading({
      title: title,
      mask: true,
      success() {
        resolve(true)
      },
      fail(err) {
        reject(err)
      }
    })
  })
}

const hideLoading = () => {
  wx.hideLoading()
}

module.exports = {
  showToast,
  showLoading,
  hideLoading
}